package org.an.proj.contacts.model;

import android.text.TextUtils;
import org.an.ku.util.StringUtil;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Property;

/**
 * Created by Fcy on 2016/10/15.<br/>
 */
@Entity(nameInDb = "tbl_phone") public class PhoneInfo {
  @Id(autoincrement = true) private Long id;
  /**
   * 通过 contactId关联表tbl_contact {@link ContactInfo#id}
   */
  @Property(nameInDb = "contactId") private long contactId;

  /**
   * 电话类型：1表示
   */
  //	@PhoneType
  private int type;

  /**
   * 电话描述：shouji
   */
  private String desc;

  //	@IntDef({TYPE_PHONE, type_jiayong, type_})
  //	@Retention(RetentionPolicy.SOURCE)
  //	private @interface PhoneType {
  //	}

  private String num;

  public String getNum() {
    return this.num;
  }

  public void setNum(String num) {
    this.num = num;
  }

  public int getType() {
    return this.type;
  }

  public void setType(int type) {
    this.type = type;
  }

  public long getContactId() {
    return this.contactId;
  }

  public void setContactId(long contactId) {
    this.contactId = contactId;
  }

  public Long getId() {
    return this.id;
  }

  public void setId(Long id) {
    this.id = id;
  }

  public String getDesc() {
    return this.desc;
  }

  public void setDesc(String desc) {
    this.desc = desc;
  }

  @Generated(hash = 1051545344)
  public PhoneInfo(Long id, long contactId, int type, String desc, String num) {
    this.id = id;
    this.contactId = contactId;
    this.type = type;
    this.desc = desc;
    this.num = num;
  }

  @Generated(hash = 1353546919) public PhoneInfo() {
  }

  public PhoneInfo getDefaultPhone() {
    this.type = 1;
    this.desc = "手机";
    return this;
  }

  /**
   * 电话是否有效
   */
  public boolean isInvalid() {
    return StringUtil.isTrimNull(num);
  }

  @Override public String toString() {
    return "PhoneInfo{" +
      "num='" + num + '\'' +
      ", desc='" + desc + '\'' +
      '}';
  }
}
